<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
    <script>
        //es5通过自定义构造函数实现实例化对象方式
        // function phone(brand,price){
        //     this.brand = brand;
        //     this.price = price;
        // };
        // phone.prototype.call = function(){
        //     console.log("我可以打电话！");
        // };
        // let realme = new phone("大师探索版",3100);
        // console.log(realme);


        // function student(name, age, likename) {
        //         this.name = name;
        //         this.age = age;
        //         this.likename = likename;
        //     };                              //1

        //     var studentproto = {
        //         like: function () {
        //             console.log(this.name + "喜欢" + this.likename);
        //         },
        //         is: function () {
        //             console.log(this.name + "属于小圣贤庄");
        //         }
        //     };                                  //2

        //     student.prototype = studentproto;	//3

        //     var d1 = new student("子羽", 23, "虞姬");
        //     var d2 = new student("子明", 18, "月儿");
        //     console.log(d1);
        //     console.log(d2);                


        //es6通过class方式实现实例化对象
        class phone {
            constructor(brand, price) {
                this.brand = brand;
                this.price = price;
            };
            call() {
                console.log("我可以打电话！");
            };
        };
        let xiaomi = new phone("红米K50", 3999);
        console.log(xiaomi);

	// 类和构造函数区别：
	// 	类必须用new创建实例对象
	// 	类不存在变量提升
	// 	类不能枚举


    </script>
</body>

</html>